package variabilitysmelldetection.measurement.measures.component;

import java.util.List;

import variabilitysmelldetection.measurement.measures.Measure;
import variabilitysmelldetection.measurement.models.ComponentItem;
import variabilitysmelldetection.measurement.models.Item;



public class NumberOfConstantRefinements extends Measure {

	public NumberOfConstantRefinements() {
		super("Number of Constant Refinements", "NCR");
	}

	public void measure(List<ComponentItem> items){
		int numOfRefinements = 0;
		for (ComponentItem item : items) {
			numOfRefinements = 0;
			
			if (!item.isRefinement()) {
				
				for (Item i : items) {
					
					if (i.isRefinement() && 
							!item.getParentName().equals(i.getParentName()) && 
							item.getName().equals(i.getName())) {
						numOfRefinements++;
					}
				}
			}
			NumberOfConstantRefinements nrc = new NumberOfConstantRefinements();
			nrc.setValue(numOfRefinements);
			item.addMeasure(nrc);
		}
	}
}
